/*
 * Options.cs
 * 
 * Property bag for application options -- populated first by app.config file, then by 
 * command line or GUI interaction.
 */
using System;
using System.Configuration;

namespace Jitsu
{
    internal class Options
    {
        //
        // Initialization

        public Options()
        {
            // Load defaults from app.config. //todo: drive this via reflection?
            string val;

            val = ConfigurationSettings.AppSettings["DoRecursion"];
            if (val == null || val == String.Empty)
                DoRecursion = false;
            else
                DoRecursion = Boolean.Parse(val);

            val = ConfigurationSettings.AppSettings["RegexIgnoreCase"];
            if (val == null || val == String.Empty)
                RegexIgnoreCase = false;
            else
                RegexIgnoreCase = Boolean.Parse(val);

            val = ConfigurationSettings.AppSettings["RegexSingleline"];
            if (val == null || val == String.Empty)
                RegexSingleline = false;
            else
                RegexSingleline = Boolean.Parse(val);

            val = ConfigurationSettings.AppSettings["RegexMimicVS"];
            if (val == null || val == String.Empty)
                RegexMimicVS = false;
            else
                RegexMimicVS = Boolean.Parse(val);

            val = ConfigurationSettings.AppSettings["OutputWidth"];
            if (val == null || val == String.Empty)
                OutputWidth = 78;
            else
                OutputWidth = UInt16.Parse(val);

            // The following parameters have no configurable defaults -- they are specified 
            // explicitly by the user, via cmd line args or GUI prompt.
            BaseDirectory = null;
            FilePattern = null;

            RegexPattern = null;
            ReplacementText = null;
        }

        //
        // Interface

        public bool DoRecursion;
        public bool RegexIgnoreCase;
        public bool RegexSingleline;
        public bool RegexMimicVS;
        public ushort OutputWidth;

        public string BaseDirectory;
        public string FilePattern;
        public string RegexPattern;
        public string ReplacementText;
    }
}